1. Field of Invention
Embodiments of the invention generally relate to graphics processing systems, and in particular, to context switching in a graphics processing system.
2. Discussion of Related Art
Today, most computer systems include graphics processing systems that process 2D graphics data, 3D graphics data and video data. Examples of tasks that may be assigned to a graphics processing system include displaying a spread sheet, displaying a video stream, or rendering a 3D video game scene. Graphics processing systems may include a circuit board or integrated circuit (e.g., a chip) sometimes referred to as a graphics engine. Further, the graphics engine may include a graphics processing unit (e.g., graphics processor). Often, the graphics processor includes a plurality of processing modules arranged in a pipeline where the modules receive data from the preceding module in the pipeline.
In a multi-tasking computer system, applications convert video streams, 2D objects and 3D objects into command lists that may be executed by the graphics processing system. Standard graphics systems receive and process one or more command lists to produce an image or frame which may be displayed on a monitor or stored in a memory. A command list can include geometric data, instructions and state information. Often, command lists are forwarded by an application to a host computer to be executed by the graphics processing system. Commands such as “write to memory,” “read from memory,” etc. are some examples of instructions which can be included in a command list.
Generally, geometric data includes primitives, such as points, lines, triangles, polygons or surfaces that provide the “building blocks” that are used to complete an object or objects when they are presented together in an image. A primitive may be described by a set of vertices with their corresponding attributes such as position, color, depth, texture coordinates, etc. Further, a primitive is associated with one or more pixels in a display where an image including the primitive is to be displayed. FIG. 5 illustrates an example in which a primitive 51 is a first triangle to be presented in an area 52 of a display. FIG. 5 includes regions 54 (outlined in phantom) of the primitive 51 that lie outside of the area 52. Accordingly, some graphics processing systems may represent the primitive 51 as a set of sub-primitives which are elements that can be combined to represent the primitive, for example, the portion of the primitive that is located within the area 52. Generally, the sub-primitive is a result of a partitioning of a larger primitive into a plurality of regions. For example, as illustrated in FIG. 5, sub-primitives 53 (i.e., four triangles, respectively) represent different regions of the primitive 51 that lie within the area 52. The set of these sub-primitives is combined to represent the primitive 51. Further, each of the primitive and the sub-primitives include one or more pixels in the area 52.
Generally, state information provides the graphics processing unit with information regarding how to process a primitive. For example, each level of the graphics pipeline (e.g., each module of a graphics pipeline) includes static and dynamic states. Static states configure the graphics engine to process a given primitive. In general, dynamic states are a result of internal computations. Accordingly, dynamic states often change during the processing of a primitive. The primitive's shape, lighting, shading information, and textures are examples of states.
FIG. 1, illustrates a system 10 including a host system 11 that includes a host processor 12 and a system memory 13, a graphics processing system 14 that includes a graphics processor 15 and a local memory 16, and an output 17. In the illustrated embodiment, the host processor 12 is connected to the system memory 13, and the graphics processor 14 is connected to the local memory 16. Further, in the illustrated embodiment, the host system 11 is connected to the graphics processing system 14 and the graphics processing system 14 is connected to the output 17. As will be recognized by those of skill in the art, another embodiment of a graphics processing system 14 may include a graphics processor 15 without including a local memory [ml]. Further, system 10 may include a plurality of I/O connections (e.g., the I/O connections may be used to connect the system 10 to a keyboard, a mouse, etc.) and additional processing components that are not illustrated in FIG. 1.
In general, the host processor 12 generates a list of commands to be executed by the graphics processor 15 which are stored in the system memory 13 or in the local memory 16. The graphics processor 15 can retrieve data from system memory 13 or from local memory 16 and execute the list of commands retrieved from the memory. Further, the output of the graphics processor 15 may be stored in the local memory 16 or the system memory 13 or it may be communicated to the output 17. The output 17 may be connected to a display screen, a storage device (e.g., a hard drive) or a communication link (e.g., an Ethernet cable).
Each command list is associated with a general state of the graphics processing system. The general state is referred to as a context. For example, a first context may be associated with the execution of a first command list or first set of command lists. In this example, a second context may be associated with the execution of a second command list or a second set of command lists.
Current computing systems frequently seek immediate access to the graphics processing system for the processing of a second context while the graphics processing system is processing a first context. That is, an operating system may prioritize the processing such that the processing of the second context should interrupt the processing of the first context. For example, the host processor of a computer system may receive a request from an application for immediate access to the graphics processing system while the system is processing a context associated with a different application. As one specific example, the computer system may have both a 3D game application and a video streaming application running simultaneously. The video application may need to refresh a frame on the screen while a 3D game scene is being rendered. Where a system is unable to efficiently switch context, the refreshing of the video frame may be considerably delayed (e.g., refreshing may not be completed on time) because the processing of the 3D scene may take a relatively long time.
The graphics processing system may receive command lists from the host processor in a variety of ways. In one existing approach, the graphics processing system receives a first command list. A subsequent command list is not communicated to the graphics processing system until the graphics processing system completes the processing of the first command list. Thus, in this approach, the graphics processing system cannot switch from a first context to a second context because the graphics processing system must complete the execution of the first command list before switching to the subsequent command list (e.g., a command list that is associated with a second context). This approach also requires that the host processor wait for the graphics engine to send an end of processing signal before providing a second list of commands. As a result, the graphics processing system may remain inactive for a considerable period before receiving a new command list to process.
In another approach, the graphics processing system receives a plurality of command lists from the system. For example, the host processor may put a plurality of lists in a command buffer from which the graphics processor may read a first command list. A variety of methods, known in the art, are used to fill out the command buffer so that once the graphics processor finishes processing a first command list; it immediately starts a second one. Here too, the processing of the command lists proceeds serially and does not provide an opportunity to switch between context.
Some prior approaches have attempted to context switch a graphics processing system before completion of a then-current context. For example, prior approaches have attempted to switch from a first context to a second context and then later return to the first context to complete it.
One approach employs a driver, executed on the host processor, to control the context switching. To interrupt the processing of a first context during processing, the driver sends a request to the graphics processing unit to stop processing the first command list. The driver also manages a saving of the graphics processor first context and communicates a second command list to the graphics processing unit. According to this approach, however, the graphics processing unit continues to process all primitives associated with the first command list which are already fetched by the input assembler before processing the second command list associated with the second context. As a result, this approach is inefficient in switching context because of the continued processing of the first command list before a context switch is made.
Another approach employs a secondary rasterizer connected to a pixel shader. In this approach, the secondary rasterizer is smaller and simpler than the main rasterizer and is limited to processing a very specific type of primitive. Here, the graphics processor stops the main rasterizer upon receipt of a request to switch from a first context to a second context and sends the second command list to the secondary rasterizer. However, this approach fails to provide for context switching of any of the more complex command lists which may also require a context switch. In addition, a single rasterizer is not used to process the first context and the second context.